import * as R from 'ramda';
interface SendMsg {
  code:number | string;
  msg:string;
  params:any;
}

const message = R.curry((code:number | string, msg:string, params?:any):SendMsg => {
  return {
    code,
    msg,
    params
  }
})

const success = message(200, '请求成功');

const error = message(404);

interface Messages {
  [key:string]: any;
}

const msgs:Messages = {
  success,
  error
};

export default (key:string, ...args:Array<any>) => msgs[key] && msgs[key](...args)
